package com.aaa.controller.api;

import com.aaa.entity.Dept;
import com.aaa.entity.OperLog;
import com.aaa.service.OperLogService;
import com.aaa.vo.DeptVo;
import com.aaa.vo.OperLogVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/api/operLog")
public class OperLogControllerApi {
    @Autowired
    private OperLogService operLogService;


    //分页查询
    @PostMapping("searchOperLog/{currentPage}/{pageSize}")
    public Result<IPage<OperLog>> searchDept(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody OperLogVo operLogVo){
        return operLogService.findByConditions(currentPage, pageSize, operLogVo);
    }


    //删除
    @DeleteMapping("delById/{id}")
    public Result delById(@PathVariable Integer id){
        if (operLogService.delById(id)){
            return new Result(200,"修改成功",true);
        }else {
            return  new Result(500,"修改失败",false);
        }
    }
    @PostMapping("delListById")
    public Result delListByid(@RequestBody List<OperLog> operLogList){
        operLogList.forEach((OperLog operLog)->{
            operLogService.removeById(operLog.getOperId());
        });
        return new Result(200,"批量删除成功",true);
    }

}
